<div>
  <div style="overflow: auto;" class="GridView">
    <div style="overflow: auto;" class="GridView" id="SearchFilterListView">
      <div>
        <div style="" class="TitleBarView">
          <h1><?php echo $this->navText;?></h1>
        </div>
      </div>
      <div>
        <div style="overflow: auto;" class="SearchView SearchView ModelView ConfigurableMetadataView MetadataView" id="AccountsSearchView">
          <div class="wide form">
              <table>
                <colgroup>
                <col style="width:20%">
                <col style="width:30%">
                <col style="width:20%">
                <col style="width:30%">
                </colgroup>
                <tbody class="search-view-bottom-panel">
                  <tr>
                    <td colspan="4">
                        <?php echo CHtml::link('章节排序', 'javascript:;', array('onClick'=>'jQuery("#chapter_order").dialog("open")'));?> 
                        &nbsp;|&nbsp;
                    	<?php echo CHtml::link('新建章节', array('create', 'bookFlag'=>$book->nameFlag))?>
                    	&nbsp;|&nbsp;
                    	<?php echo CHtml::link('查看本书前台目录', array('book/preview', 'bookFlag'=>$book->nameFlag), array('target'=>'_blank'))?>
                    	&nbsp;|&nbsp;
                      <?php echo CHtml::link('返回书籍管理', array('book/index'));?>
                    </td>
                  </tr>
                </tbody>
              </table>
            </form>
          </div>
        </div>
      </div>
      <div>
        <div style="overflow: auto;" class="SecuredListView ListView ModelView ConfigurableMetadataView MetadataView" id="AccountsListView">
          <div class="view-toolbar"></div>
          <div id="list-view" class="cgrid-view">
            <table class="items"  style="table-layout:fixed">
              <thead>
                <tr>
                  <th id="list-view_c1" style="width:5%">章节Id</th>
                  <th id="list-view_c2" style="width:5%">排序</th>
                  <th id="list-view_c3" style="width:5%">首章</th>
                  <th id="list-view_c4" style="width:5%">尾章</th>
                  <th id="list-view_c5" style="width:10%">标识</th>
                  <th id="list-view_c6" style="width:15%">中文名称</th>
				  <th id="list-view_c7" style="width:15%;">英文</th>
                  <th id="list-view_c8" style="width:5%;">添加锁</th>
                  <th id="list-view_c9" style="width:5%;">类型锁</th>
                  <th id="list-view_c10" style="width:5%;">修改锁</th>
                  <th id="list-view_c11" style="width:5%;">排序锁</th>
                  <th id="list-view_c12" style="width:5%;">翻译锁</th>
                  <th id="list-view_c13" class="button-column" style="width:20%;">操作</th>
                </tr>
              </thead>
              <tbody>
              	<?php if ($chapters==false) :?>
                <tr>
                  <td colspan="8"><span class="empty">无记录</span></td>
                </tr>
                <?php else :?>
                <?php foreach($chapters as $chapter) :?>
	                <tr>
	                  <td><?php echo $chapter['chapterId']?></td>
	                  <td><?php echo CHtml::encode($chapter['chapterSort']);?></td>
	                  <td><?php echo $chapter['isFirst']==1? 'Y' : 'N';?></td>
	                  <td><?php echo $chapter['isEnd']==1? 'Y' : 'N';?></td>
	                  <td><?php echo CHtml::encode($chapter['url'])?></td>
	                  <td><?php echo CHtml::link($chapter['chapterName'], 
	                  								array('/book/default/chapter', 
	                  											'bookFlag'=>$book->nameFlag, 'chapterFlag'=>$chapter['url']
	                  										),
	                  							array('target'=>'_blank')
	                  						);?>
	                  </td>
	                  <td><?php echo CHtml::encode($chapter['originalChapterName']);?></td>
	                  <td><?php echo $chapter['isAddLock']==1? 'Y' : 'N';?></td>
	                  <td><?php echo $chapter['isTypeLock']==1? 'Y' : 'N';?></td>
	                  <td><?php echo $chapter['isUpdateLock']==1? 'Y' : 'N';?></td>
	                  <td><?php echo $chapter['isSortLock']==1? 'Y' : 'N';?></td>
	                  <td><?php echo $chapter['isTranslateLock']==1? 'Y' : 'N';?></td>
	                  <td>
	                  <?php echo CHtml::link('修改章节', array('chapter/update', 'bookFlag'=>$book->nameFlag, 'chapterFlag'=>$chapter['url']));?>
	                   | 
	                  <?php echo CHtml::link('段落管理', array('section/index', 'bookFlag'=>$book->nameFlag, 'chapterFlag'=>$chapter['url']));?>
	                  </td>
	                </tr>
	            <?php endforeach; ?>
                <?php endif;?>
                
              </tbody>
            </table>
            <div title="/index.php?r=accounts/default" style="display:none" class="keys"></div>
          </div>
          <input type="hidden" id="list-view-selectedIds" name="list-view-selectedIds" value="">
          <input type="hidden" id="list-view-selectAll" name="list-view-selectAll" value="">
        </div>
      </div>
    </div>
  </div>
</div>
<?php 
Yii::app()->getClientScript()->registerScript('chapter_order', "
jQuery('#_order').click(function() {
	jQuery.ajax({
		'type':'post',
		'url':'". $this->createUrl('chapter/order', array('bookFlag'=>$book->nameFlag)) ."',
		'data':{
			'ChapterOrderForm[begin_num]':jQuery('#SectionOrderForm_begin_num').val(),
			'ChapterOrderForm[setp_num]':jQuery('#SectionOrderForm_setp_num').val()
        },
		'dataType':'json',
		'success':function(data, status) {
			jQuery('#chapter_order').dialog('close');
			location.href='". $this->createUrl('chapter/index', array('bookFlag'=>$book->nameFlag)) ."';
		},
		'error':function(data, status) {
			alert(error);
		}
	});

});

");
?>
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array('id'=>'chapter_order', 'options'=>array('modal'=>true, 'maxWidth'=>600, 'minWidth'=>600, 'maxHeight'=>450, 'minHeight'=>450, 'title'=>'章节排序', 'autoOpen'=>false)));
?>
<div style="overflow: auto;" id="ModalView">
<div id="modalContainer">
<div style="overflow: auto;" class="MyListConfigView ModalConfigEditView EditView DetailsView ModelView ConfigurableMetadataView MetadataView">

<div class="wide form">
<table><colgroup><col style="width:20%"><col style="width:80%"></colgroup>
<tbody>
<tr><th><label for="SectionOrderForm_begin_num">开始数值</label></th><td colspan="1"><input type="text" value="100" name="SectionOrderForm[begin_num]" id="SectionOrderForm_begin_num">
<div style="display:none" id="SectionOrderForm_begin_num_em_" class="errorMessage"></div>会按此数值递减</td></tr>
<tr><th><label for="SectionOrderForm_setp_num">步长</label></th><td colspan="1"><input type="text" value="1" name="SectionOrderForm[setp_num]" id="SectionOrderForm_setp_num">
<div style="display:none" id="SectionOrderForm_setp_num_em_" class="errorMessage"></div>递减步长</td></tr>
</tbody></table>
此操作会按当前现有排序，更新排序数值
<div class="modal-view-toolbar"><input type="button" value="开始排序" name="save" id="_order"></div></form></div></div></div></div>
<?php 
$this->endWidget(); 
?>
